/**
 * creation: 15-may-08
 */

package org.jfonia.connect;

/**
 * Value which holds a copy of the value of its source, and updates this copy when called.
 * 
 * @author wijnand.schepens@gmail.com
 *
 * @param <T>
 */
public class Cache<T> extends BasicNode implements Value<T>
{
	protected T        value;
	protected Value<T> source;
	
	public Cache(Value<T> source) {
		this.source = source;
		update();
	}

	public T get() {
		return value;
	}

	public boolean callThis(Object param) {
		update();
		return true;
	}
	
	protected void update()
	{
		this.value = source.get();
		
	}

}
